package com.project.common.exception;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
public class GlobalException extends RuntimeException {

    private String msg;
    private String code;

    public GlobalException(String code, String msg) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public GlobalException(ErrorSupport errorSupport) {
        super(errorSupport.getErrorMessage());
        this.msg = errorSupport.getErrorMessage();
        this.code = errorSupport.getCode();
    }

    public GlobalException(ErrorSupport errorSupport, String msg) {
        super(errorSupport.getErrorMessage());
        this.msg = StringUtils.isBlank(msg) ? errorSupport.getErrorMessage() : msg;
        this.code = errorSupport.getCode();
    }
}
